/*
 * @Author: 霍格沃兹测试开发学社
 * @Desc: '更多测试开发技术探讨，请访问：https://ceshiren.com/t/topic/15860'
 */

package com.ceshiren.aitestmini.controller;

import com.ceshiren.aitestmini.dto.HogwartsTestUserDTO;
import com.ceshiren.aitestmini.dto.UserDto;
import com.ceshiren.aitestmini.entity.HogwartsTestUser;
import com.ceshiren.aitestmini.service.User2Service;
import com.ceshiren.aitestmini.service.UserService;
import com.ceshiren.aitestmini.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("/user")
public class UserController {

    @Autowired
    User2Service user2;


    @PostMapping(value = "/login",produces = "application/json")
    R login(@RequestBody UserDto userDto){

        return user2.login(userDto);
    }

    @PostMapping(value = "/reg",produces = "application/json")
    R registerUser(@RequestBody HogwartsTestUser hogwartsTestUser){

        return user2.register(hogwartsTestUser);
    }


    @GetMapping(value = "/find", produces = "application/json")
    R findUser(@RequestParam HogwartsTestUser hogwartsTestUser){

        return user2.find(hogwartsTestUser);
    }


    @PostMapping(value = "/update",produces = "application/json")
    R updateUser(@RequestBody HogwartsTestUserDTO hogwartsTestUserDTO){

        return user2.update(hogwartsTestUserDTO);
    }


    @PostMapping(value = "/delete",produces = "application/json")
    R deleteUser(@RequestBody HogwartsTestUser hogwartsTestUser){

        return user2.delete(hogwartsTestUser);
    }

}
